package com.itwn.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.itwn.entity.Order;
import com.itwn.entity.User;
import com.itwn.mapper.OrderDetailsMapper;
import com.itwn.mapper.OrderMapper;
import com.itwn.mapper.UserMapper;
import com.itwn.vo.ManagerVo;
import com.itwn.vo.OrderVo;
import com.sun.org.apache.xpath.internal.operations.Or;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OrderService {
    @Autowired
    OrderMapper orderMapper;
    public PageInfo<OrderVo> queryAllOrder(String orderNo, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<OrderVo> managerList = orderMapper.findAllorder(orderNo);
        return new PageInfo<>(managerList);
    }

    public int modifyOrder(OrderVo order) {
        return orderMapper.updateByPrimaryKey(order);
    }

    public int removeOrder(String orderNo) {
        return orderMapper.deleteByPrimaryKey(orderNo);
    }

    @Autowired
    OrderDetailsMapper orderDetailsMapper;
    public int removeOrderDetail(String orderNo) {
        return orderDetailsMapper.deleteByPrimaryKey(orderNo);
    }

    @Autowired
    UserMapper userMapper;
    public User selectUserByName(String userName) {
        return userMapper.selectByPrimaryKey(userName);
    }
}
